<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            position: relative;
            width: 400px;
            height: 30px;
            border-bottom: 1px solid black;
            margin: 100px auto;

        }

        div input {
            width: 390px;
            height: 27px;
            border: none;
            outline: none;
        }

        div img {
            position: absolute;
            top: 5px;
            right: 10px;
            width: 20px;
            height: 20px;
        }
    </style>
</head>
<body>
    <div>
        <label for="">
            <img src="/pink/imgs/zyz_txt/眼睛.png" alt="" id="img">
        </label>
        <input type="password" id="ipt">
    </div>
    <script>
        var img = document.getElementById('img')
        var ipt = document.getElementById('ipt')

        let flag = 0;
        img.onclick = () => {
            if (flag == 0) {
                ipt.type = 'text';
                img.src = "/pink/imgs/不可见.png";
                flag = 1;
            } else {
                ipt.type = "password";
                img.src = "/pink/imgs/zyz_txt/眼睛.png";
                flag = 0;
            }
        }
    </script>
</body>
</html>